 //513.找树左下角的值
 //https://leetcode.cn/problems/find-bottom-left-tree-value/
class Solution {
public:
    int findBottomLeftValue(TreeNode* root) {
        if(root == nullptr) return -1;
        queue<TreeNode*> q;
        q.push(root);
        int ret = 0;
        //我们只需要将遍历顺序颠倒 右节点先遍历 最后留下的肯定是左节点
        while(!q.empty())
        {
            TreeNode* node = q.front(); q.pop();
            if(node->right) q.push(node->right);
            if(node->left) q.push(node->left);
            ret = node->val;
        }
        return ret;
    }
};